var PW = PW || {};

PW.confirmBooking = {

    options:function () {
    },

    load:function () {
    },

    el:{ },

    events:function () {
        $('[name=form_email]').on('change', function () {
            var data = {
                'action':'user_exists',
                'form_email':$('[name=form_email]').val()
            };

            $.post('/service/', data, function (data) {
                data = jQuery.parseJSON(data);
                console.log(data);
                console.log(data.info);
                if (data.info) {
                    //$('#email-help').html('OK')
                    $('#email-help').html('User already exists, please <a href="#loginModal" data-toggle="modal">log in</a>.')
                    $('#email-help').slideDown();
                    $('#payment-link').attr('disabled','disabled');
                } else {
                    $('#email-help').slideUp();
                    $('#payment-link').removeAttr('disabled');
                }
            });
        });
    },

    init:function () {
        this.options();
        this.load();
        this.events();
    }
};


